% Test the function makeppft filter.
%
% Yoel Shkolnisky, December 2010.

explim=8;
for n=2.^(1:explim)
	precision='double';
	if n > 2^(explim-1)
		precision='single';
	end
    A=rand(n,n);
    
    tic;
    [pp1 pp2]=optimizedPPFT2D(A,precision);
    B=optimizedAdjointPPFT2D(pp1,pp2,precision);
    t1 = toc;

    H=makePPFTFilter2D(n,precision);

    hp=zeros(3*n,3*n,precision);
    hp(n/2+1:5*n/2,n/2+1:5*n/2)=H.filter;
    Hhat=fftn(ifftshift(hp));
    
    tic;
    Ap=zeros(3*n,3*n,precision);
    Ap(n+1:2*n,n+1:2*n)=A;
    Cc=fftshift(ifftn(fftn(ifftshift(Ap)).*Hhat));
    Cc=Cc(n+1:2*n,n+1:2*n);
    t2=toc;

    reportTestResult(n,(norm(B(:)-Cc(:))./norm(B(:))),t1/t2,precision);    
end
